<template>
  <uni-section title="下达列表" titleFontSize="35rpx" type="line">
	<uni-list>
		<uni-list-item v-for="item in fkxxList" :title="item.sxbt" :note="item.xdrq" showArrow
			thumb="/static/logo.png" thumb-size="lg" :rightText="type=='yfk'?'详细': item.sffk === '1' ? '去反馈' : '详细'"
			ellipsis="2" :to="`./${pageName}?fkId=${item.sid}&workid=${item.workid}&ly=${item.ly}`" @click="onClick"/>
	</uni-list>
<!--  <template v-slot:right>-->
<!--    <view  v-show="showBtn" class="action-btn">-->
<!--      <button @click="getFkls()" class="login-btn cu-btn  uni-success">{{btnName}}</button>-->
<!--    </view>-->
<!--  </template>-->
  </uni-section>
</template>

<script>
	import {	getFkxxByUserId,getLoginUserInfoByAppToken	} from "@/api/system/yjgl";
	import { getUserId} from '@/utils/auth';
  import app from "@/App.vue";
	export default {
		name: "index",
		data() {
			return {
				fkxxList: [],
        type:'',
        btnName:'查看反馈历史',
        pageName: 'ckRwxx',
        showBtn: true,
			};
		},
    onLoad(option) {
      if (option.type){
        this.type = option.type;
        // 我的待办跳转过来的
        this.showBtn = false;
      }
      this.editPropName(option.type);
      this.getList();
    },
		methods: {
      editPropName(type){// 根据页面不同设置不同属性
        if (type == 'yfk'){// 已反馈
          this.btnName = '查看反馈信息';
          this.pageName = 'work/ckRwxx';
        }else if (type == 'wfk'){// 未反馈
          this.btnName = '查看反馈历史';
          this.pageName = 'ckRwxx';
        }
      },
      getFkls(){// 切换页面
        if (this.type == 'wfk') {
          this.type = 'yfk';
        }
        else if (this.type == 'yfk') {
          this.type = 'wfk';
        }
        this.editPropName(this.type);
        this.getList();
      },
      getUrlParam(url){
          const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
          const params = {};
          let match;
          while (match = paramsRegex.exec(url)) {
            params[match[1]] = match[2];
          }
          return params;
      },
			//访问微信地址，用来获取code
			getWeChatCode() {
				//通过微信官方接口获取code之后，会重新刷新设置的回调地址【redirect_uri】
			 	let redirect_uri = encodeURIComponent(window.location.href)
				window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww7555960e312add1f&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_base&state=STATE&agentid=AGENTID#wechat_redirect"
			},
			// 企业微信登录
			async wxLogin(code) {
			  this.$modal.loading("登录中，请耐心等待...")
			  this.$store.dispatch('WxLogin', code).then(() => {
			    this.$modal.closeLoading()
			  })
			},
			onClick(e) {
			},
			getList() {
				getFkxxByUserId({userId:getUserId(),'type':this.type}).then(res => {
					this.fkxxList = res.data
					this.ly = res.data.ly
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #f5f6f7;
	}
</style>
